package model;

import java.util.ArrayList;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import dao.StudentDAO;


/**
 * 
 * @author 蔡锦涛
 *
 */


public class Student implements StudentDAO{
	private String name;
	private List<Course> elective = new ArrayList<>();
   
    public Student(String name){
        this.name=name;
    }
    public String getName() {
        return name;
    }

    public List<Course> getElective() {
        return elective;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setElective(List<Course> elective) {
        this.elective = elective;
    }

   

   
	
	public boolean add(Course c) {
		for (int i = 0; i < elective.size(); i++) {
			if(elective.get(i).getName().equals(c.getName())) {
				return false;
			}
		}
		elective.add(c);
		return true;
	}
	
	public boolean delete(Course c) {
		if(elective.isEmpty()) {
			return false;
		}
		for (int i = 0; i < elective.size(); i++) {
			if(elective.get(i).getName().equals(c.getName())) {
				elective.remove(i);
				return true;
			}
		}
		return false;
	}
	
}
